﻿﻿
//////// --- 读取excel文件
using System;
using System.IO;
using Newtonsoft.Json;
using YamlDotNet.Serialization;


namespace ReadYaml
{
    public class MyClient
    {
        public static string conv_yaml_to_json(string ss, bool is_file_path = true)
        {
            string yaml;
            if (is_file_path)
                yaml = File.ReadAllText(ss);
            else
                yaml = ss;

            var deserializer = new Deserializer();
            object yamlObject;
            using (var reader = new StringReader(yaml))
            {
                yamlObject = deserializer.Deserialize(reader);
            }

            string json = JsonConvert.SerializeObject(yamlObject);
            return json;
        }

        public static void run()
        {
            string file_path = "data/test.yaml";

            var json = conv_yaml_to_json(file_path);

            Console.WriteLine(json);

            var dc = BdUtils.conv_json_to_dict(json);
            // BdUtils.log($"--- age: {dc["age"]} --- name: {dc["name"]} --- images: {dc["images"]}");
            BdUtils.log(dc);
        }
    }
}
